/* eslint-disable camelcase */

/**
 * 返回体类型
 */
enum ResponseBody {
  JSON='json'
}

/**
 * 请求体类型
 */
enum RequestBody {
  JSON='json',
  FORM='form'
}

/**
 * 请求方法
 */
export enum RequestMethod {
  GET='GET',
  POST='POST'
}

/**
 * Api 状态
 */
enum ApiStatus {
  DONE='done',
  UNDONE='undone'
}

enum Required {
  TRUE='1',
  FALSE='0'
}

enum FieldType {
  TEXT='text',
  FILE='file'
}

interface RequestHeader {
  required: Required
  _id: string
  name: string
  value: string
  example: string
}

interface RequestQuery {
  required: Required
  _id: string
  name: string
  value: string
  example: string
  desc: string
}

interface RequestBodyForm {
  required: Required
  _id: string
  name: string
  type: FieldType
  example: string
  desc: string
}

interface QueryPath {
  path: string
  params: []
}

export interface Api {
  query_path: QueryPath
  edit_uid: number
  status: ApiStatus
  req_body_is_json_schema: boolean
  res_body_is_json_schema: boolean
  api_opened: boolean
  index: number
  tag: []
  _id: number
  req_body_type: RequestBody
  res_body_type: ResponseBody
  title: string
  path: string
  catid: number
  markdown: string
  method: RequestMethod
  req_headers: RequestHeader[]
  req_query: RequestQuery[]
  desc: string
  project_id: number
  uid: number
  add_time: number
  up_time: number
  req_body_form: RequestBodyForm
  res_body: string
  req_body_other: string
}

export interface GroupItem {
  index: number
  name: string
  add_time: number
  up_time: number
  list: Api[]
}

export interface ProjectInfoResponse {
  errcode: number
  errmsg: string
  data: {
    basepath: string
  }
}

export type Recordable<T = any> = Record<string, T>

export interface Method {
  name: string
  path: string
  method: string
  query: string | null
  param: string | null
  response: string | null
}
